package com.chinanet.repository.manager;

import com.chinanet.entry.manager.Defect;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;

public interface DefectRepository extends PagingAndSortingRepository<Defect, Long> {
    @RestResource(path = "notAmend",rel = "not/amend")
    @Query(value = "select d.* from defect d left join amend a on a.defect_id = d.id where  a.id <>:amendId and a.defect_id is null", nativeQuery = true)
    Page<Defect> getAllNotByAmend(@Param("amendId") long amendId, Pageable pageable);

}